try {
	Type.registerNamespace('NCMMDateUtil');
	var now = new Date(); //当前日期 
	var nowDayOfWeek = now.getDay(); //今天本周的第几天 
	var nowDay = now.getDate(); //当前日 
	var nowMonth = now.getMonth(); //当前月 
	var nowYear = now.getYear(); //当前年 
	nowYear += (nowYear < 2000) ? 1900 : 0; //  

	this.getTestDate = function() {
		return new Date('2015', '00', '-1');
	};
	/** 
	 * 获取本周起始和结束日期时间
	 */
	NCMMDateUtil.getWeekDate = function() {
		if(nowDayOfWeek == 0)
			nowDayOfWeek = 7;
		var monday = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek + 1);
		var beginWeekDate = formatDate(monday) + " 00:00:00";
		//$alert("Util-本周起始日期="+beginWeekDate);
		//本周 周日    
		var sunday = new Date(nowYear, nowMonth, nowDay + (7 - nowDayOfWeek));
		var endWeekDate = formatDate(sunday) + " 23:59:59";
		//$alert("Util-本周结束日期="+endWeekDate);
		var weekDate = {
			"beginDate": beginWeekDate,
			"endDate": endWeekDate
		};
		//$toast(weekDate.beginDate + " ~ " + weekDate.endDate);
		//返回    
		return weekDate;
	}

	/**
	 *获取本月起始和结束日期 
	 */
	NCMMDateUtil.getMonthDate = function() {
			//本月第一天
			var firstDay = new Date(nowYear, nowMonth, 1);
			var beginMonthDate = formatDate(firstDay) + " 00:00:00";
			//$alert("Util-本月起始日期 "+beginMonthDate);
			var currentMonth = nowMonth;
			var currentYear = nowYear;

			//十二月特殊处理 下一年的第一个月    
			if(currentMonth == 11) {
				currentYear++;
				currentMonth = 0;
			} else {
				currentMonth++;
			}
			//一天的毫秒数    
			var millisecond = 1000 * 60 * 60 * 24;
			//下月的第一天    
			var nextMonthDayOne = new Date(currentYear, currentMonth, 1);
			//求出上月的最后一天    
			var lastDay = new Date(nextMonthDayOne.getTime() - millisecond);
			var endMonthDate = formatDate(lastDay) + " 23:59:59"
				//$alert("Util-本月结束日期="+endMonthDate);
			var monthDate = {
				"beginDate": beginMonthDate,
				"endDate": endMonthDate
			};
			//$toast(monthDate.beginDate + " ~ " + monthDate.endDate);
			//返回    
			return monthDate;
		}
		/**
		 *获取今日起始结束日期时间
		 */
	NCMMDateUtil.getDayDate = function() {
		var beginDate = formatDate(now) + " 00:00:00";
		var endDate = formatDate(now) + " 23:59:59";
		var dayDate = {
			"beginDate": beginDate,
			"endDate": endDate
		};
		//$toast(dayDate.beginDate + " ~ " + dayDate.endDate);
		return dayDate;
	}

	/**
	 *获取今日起始结束日期时间
	 */
	NCMMDateUtil.getDay = function() {
			return formatDate(now);
	};
	
	NCMMDateUtil.getOnlyDate = function(strDatetime){
		if(strDatetime == null || strDatetime == "")
			return "";
		var temp = strDatetime.split(" ");
		if(temp.length > 0)
			return temp[0];
		else 
			return "";
	}
		/**
		 * 格局化日期：yyyy-MM-dd 
		 */
	function formatDate(date) {
		var year = date.getFullYear();
		var month = date.getMonth() + 1;
		var day = date.getDate();

		if(month < 10) {
			month = "0" + month;
		}
		if(day < 10) {
			day = "0" + day;
		}
		return(year + "-" + month + "-" + day);
	}

} catch(e) {
	$e(e);
}